import cv2 as cv
import numpy as np  

# ----------------------laplacian算子----------------

img = cv.imread('cat.jpeg', 0)  # 读取灰度图像

# 计算拉普拉斯算子
result = cv.Laplacian(img, cv.CV_16S, ksize=3)  #图像，数据类型int, 卷积核大小须为1,3,5,7

# 转换为绝对值
abs_result = cv.convertScaleAbs(result)  # 转换为绝对值

cv.imshow('Original Image', img)
cv.imshow('Laplacian Image', abs_result)

cv.waitKey(0)
cv.destroyAllWindows()

